﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BonjourHotel.Core.Menu;

namespace BonjourHotel.Application.Controls.Rooms
{
    public partial class RoomMainMenu : BaseBHMenu
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                base.GetLocalization("Room");
                btnCreateRoom.Text = CreateText;
                btnUpdateRoom.Text = UpdateText;
                btnRemoveRoom.Text = RemoveText;
                btnFindRoom.Text = FindText;
                btnSortRoom.Text = SortText;

                if (Mode == MenuMode.Create || Mode == MenuMode.Update)
                {
                    btnCreateRoom.Enabled = false;
                    btnUpdateRoom.Enabled = false;
                    btnRemoveRoom.Enabled = false;
                    btnFindRoom.Enabled = false;
                    btnSortRoom.Enabled = false;
                }
            }
        }

        public event EventHandler Create;
        public event EventHandler Update;
        public event EventHandler Remove;
        public event EventHandler Sort;
        public event EventHandler Find;


        protected void btnRoomMainMenu_Click(object sender, EventArgs e)
        {
            IButtonControl btn = (IButtonControl)sender;

            switch (btn.CommandName)
            {
                case "create":
                    if (Create != null) Create(this, null);
                    break;
                case "update":
                    if (Update != null) Update(this, null);
                    break;
                case "remove":
                    if (Remove != null) Remove(this, null);
                    break;
                case "sort":
                    if (Sort != null) Sort(this, null);
                    break;
                case "find":
                    if (Find != null) Find(this, null);
                    break;
            }
        }
    }
}